package com.example.driving.utils;


import android.icu.text.IDNA;

import androidx.lifecycle.LiveData;

import com.example.driving.base.Data;
import com.example.driving.model.ExamQuestionBean;
import com.example.driving.model.InfoBean;
import com.example.driving.model.Subject2Bean;
import com.example.driving.model.UserBean;
import com.github.leonardoxh.livedatacalladapter.Resource;

import java.util.List;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface Api {

    /**
     * 根据科目类型返回所有的视频
     *
     * @return
     */
    @GET("Video/subject/{id}")
    Call<Data<List<Subject2Bean>>> getVideoList(@Path("id") int id);


    /**
     * 查询科目类型题目题库
     *
     * @return
     */
    @GET("ExamQuestion/all")
    Call<Data<List<ExamQuestionBean>>> allExamQuestion(@Query("subject") int subject);


    /**
     * 收藏
     *
     * @param userId
     * @param questionId
     * @return
     */
    @POST("ExamCollect/add")
    Call<Data<String>> addExamCollect(@Query("userId") Long userId,
                                      @Query("questionId") int questionId);

    @GET("ExamCollect/CollectByUserId")
    Call<Data<String>> CollectByUserId(@Query("userId") Long userId,
                                       @Query("questionId") int questionId);

    @GET("ExamCollect/all")
    Call<Data<List<ExamQuestionBean>>> allCollect(@Query("userId") Long userId);

    @DELETE("ExamCollect/del")
    Call<Data<String>> delCollect(@Query("userId") Long userId,
                                  @Query("questionId") int questionId);


    /**
     * 错题题库
     * http://localhost:8080/ExamQuestion/Error?id=1
     */
    @GET("ExamQuestion/Error")
    Call<Data<List<ExamQuestionBean>>> ErrorExamQuestion(@Query("id") Long id);


    /**
     * 题库
     *  http://localhost:8080/ExamQuestion/rand?number=100&userId=1&subject=1&type=1
     */


    @GET("ExamQuestion/rand")
    Call<Data<List<ExamQuestionBean>>> randExamQuestion(@Query("number") int number,
                                                        @Query("userId") Long userId,
                                                        @Query("subject") int subject,
                                                        @Query("type") int type);


    /**
     *     交卷接口
     *
     *     将错误的题目进行权重的上升
     * http://localhost:8080/ExamErrors/rise?id=1
     *
     *     将正确的题目进行权重下降
     * http://localhost:8080/ExamErrors/drop?id=1
     */

    @PUT("ExamErrors/rise")
    Call<Data<String>> examRise(@Query("id") Long id,@Body List<ExamQuestionBean> examQuestionBeans);

    @PUT("ExamErrors/drop")
    Call<Data<String>> examDrop(@Query("id") Long id,@Body List<ExamQuestionBean> examQuestionBeans);


    /**
     * 用户接口
     */

    @POST("user/Login")
    Call<Data<UserBean>> Login(@Body UserBean userBean);


    @POST("user/Register")
    Call<Data<UserBean>> register(@Body UserBean userBean);

    @GET("user/info")
    Call<Data<InfoBean>> info(@Query("id") Long id, @Query("subject") int subject);


    @GET("user/examOK")
    Call<Data<String>> examOK(@Query("id") Long id, @Query("score") int score);


}
